home *** CD-ROM | disk | FTP | other *** search
/ Click Press Kit / Click Press Kit.iso / pc / main.dxr / Internal_19_newRemoting.swf / scripts / frame_1 / DoAction.as
Encoding:
Text File  |  2006-05-31  |  63.3 KB  |  2,346 lines

  1. function getNetDebugVersion()
  2. {
  3.    return 1;
  4. }
  5. function NetDebugConfig()
  6. {
  7. }
  8. function attachNetDebugConfigFunctions(ndc)
  9. {
  10.    ndc.setDebug = function(setval)
  11.    {
  12.       this.m_debug = setval;
  13.    };
  14.    ndc.getDebug = function()
  15.    {
  16.       return this.m_debug;
  17.    };
  18.    for(var prop in ndc)
  19.    {
  20.       if(typeof ndc[prop] == "object")
  21.       {
  22.          attachNetDebugConfigFunctions(ndc[prop]);
  23.       }
  24.    }
  25. }
  26. function getDefaultNetDebugConfig(iscontroller)
  27. {
  28.    if(_global.netDebugConfigSO == undefined)
  29.    {
  30.       var soName = "TestMovie_Config_Info";
  31.       if(iscontroller)
  32.       {
  33.          soName = "Controller_Config_Info";
  34.       }
  35.       _global.netDebugConfigSO = SharedObject.getLocal(soName);
  36.    }
  37.    if(_global.netDebugConfigSO.data.config == undefined)
  38.    {
  39.       _global.netDebugConfigSO.data.config = getRealDefaultNetDebugConfig();
  40.    }
  41.    _global.netDebugConfigSO.flush();
  42.    return _global.netDebugConfigSO.data.config;
  43. }
  44. function getRealDefaultNetDebugConfig()
  45. {
  46.    var defaultConfig = new NetDebugConfig();
  47.    defaultConfig.m_debug = true;
  48.    defaultConfig.client = new NetDebugConfig();
  49.    defaultConfig.client.m_debug = true;
  50.    defaultConfig.client.trace = true;
  51.    defaultConfig.client.recordset = true;
  52.    defaultConfig.client.http = true;
  53.    defaultConfig.client.rtmp = true;
  54.    defaultConfig.realtime_server = new NetDebugConfig();
  55.    defaultConfig.realtime_server.m_debug = true;
  56.    defaultConfig.realtime_server.trace = true;
  57.    defaultConfig.app_server = new NetDebugConfig();
  58.    defaultConfig.app_server.m_debug = true;
  59.    defaultConfig.app_server.trace = true;
  60.    defaultConfig.app_server.error = true;
  61.    defaultConfig.app_server.recordset = true;
  62.    defaultConfig.app_server.httpheaders = false;
  63.    defaultConfig.app_server.amf = false;
  64.    defaultConfig.app_server.amfheaders = false;
  65.    defaultConfig.app_server.coldfusion = true;
  66.    return defaultConfig;
  67. }
  68. function NetDebugEvent()
  69. {
  70. }
  71. function NetDebugErrorEvent(dataobj)
  72. {
  73.    this.init();
  74.    this.EventType = "NetDebugError";
  75.    this.Error = dataobj;
  76. }
  77. function NetDebugTraceEvent(traceobj)
  78. {
  79.    this.init();
  80.    this.EventType = "Trace";
  81.    this.Trace = traceobj;
  82. }
  83. function NetDebugTraceNetServicesEvent(w, s, n, m)
  84. {
  85.    this.init();
  86.    this.EventType = "NetServicesTrace";
  87.    this.Trace = m;
  88.    this.Who = w;
  89.    this.Severity = s;
  90.    this.Number = n;
  91. }
  92. function NetDebugNCEvent()
  93. {
  94. }
  95. function NetDebugResultEvent(resultobj)
  96. {
  97.    this.init();
  98.    this.EventType = "Result";
  99.    this.Result = resultobj;
  100. }
  101. function NetDebugStatusEvent(statusobj)
  102. {
  103.    this.init();
  104.    this.EventType = "Status";
  105.    this.Status = statusobj;
  106. }
  107. function NetDebugConnectEvent(args)
  108. {
  109.    this.init();
  110.    this.EventType = "Connect";
  111.    this.ConnectString = args[0];
  112.    if(args[1] != null)
  113.    {
  114.       this.UserName = args[1];
  115.    }
  116.    if(args[2] != null)
  117.    {
  118.       this.Password = args[2];
  119.    }
  120. }
  121. function NetDebugCallEvent(args)
  122. {
  123.    this.init();
  124.    this.EventType = "Call";
  125.    this.MethodName = args[0];
  126.    this.Parameters = new Array();
  127.    var i = 2;
  128.    while(i < args.length)
  129.    {
  130.       this.Parameters[i - 2] = args[i];
  131.       i++;
  132.    }
  133. }
  134. function NetDebugCloseEvent()
  135. {
  136.    this.init();
  137.    this.EventType = "Close";
  138. }
  139. function NetDebugAddHeaderEvent(args)
  140. {
  141.    this.init();
  142.    this.EventType = "AddHeader";
  143.    this.HeaderName = args[0];
  144.    this.MustUnderstand = args[1];
  145.    if(args[2] != null)
  146.    {
  147.       this.HeaderObject = args[2];
  148.    }
  149. }
  150. function NetDebugRtmpLogEvent(infoobj)
  151. {
  152.    this.initDate();
  153.    this.EventType = "Trace";
  154.    this.Source = "Flash Communication Server";
  155.    this.Info = infoobj;
  156.    this.Trace = infoobj.description;
  157. }
  158. function NetDebugDuplicateNCDErrorEvent()
  159. {
  160.    this.initDate();
  161.    this.EventType = "Error";
  162.    this.Source = "NCD";
  163.    this.Message = "NCD_ALREADY_RUNNING";
  164. }
  165. function NetDebugFailedSendErrorEvent(ev)
  166. {
  167.    this.initDate();
  168.    this.EventType = "Error";
  169.    this.Source = "NCD";
  170.    this.OriginalEvent = ev;
  171.    this.Message = "NCD_FAILED_TO_SEND_EVENT";
  172. }
  173. function NetDebugInfoErrorEvent(infoobj, mes)
  174. {
  175.    this.initDate();
  176.    this.EventType = "Error";
  177.    this.Source = "NCD";
  178.    this.Info = infoobj;
  179.    if(mes != null)
  180.    {
  181.       this.Message = mes;
  182.    }
  183. }
  184. function NetDebugReceiveCallEvent(mName, args)
  185. {
  186.    this.init();
  187.    this.EventType = "ReceivedCall";
  188.    this.MethodName = mName;
  189.    this.Parameters = args;
  190. }
  191. function netDebugProxyConnect()
  192. {
  193.    this.attachDebug();
  194.    var proto = arguments[0].substr(0,4);
  195.    if(proto == "http" || proto == "rtmp")
  196.    {
  197.       this.m_Protocol = proto;
  198.    }
  199.    else
  200.    {
  201.       this.m_Protocol = "http";
  202.    }
  203.    this.sendClientEvent(new NetDebugConnectEvent(arguments));
  204.    if(this.isRealTime())
  205.    {
  206.       this.m_ConnectString = arguments[0];
  207.       getNetDebug().sendCommand(new StartRTMPTraceCommand(arguments[0]));
  208.       var ret = this.realconnect.apply(this,arguments);
  209.       this.realcall("@getClientID",new RTMPClientIDResponse(arguments[0],this));
  210.       return ret;
  211.    }
  212.    return this.realconnect.apply(this,arguments);
  213. }
  214. function netDebugProxyCall()
  215. {
  216.    this.attachDebug();
  217.    this.sendClientEvent(new NetDebugCallEvent(arguments));
  218.    this.addNetDebugHeader();
  219.    if(this.m_Config.app_server)
  220.    {
  221.       arguments[1] = new NetDebugResponseProxy(this,arguments[1]);
  222.       return this.realcall.apply(this,arguments);
  223.    }
  224.    return this.realcall.apply(this,arguments);
  225. }
  226. function netDebugProxyClose()
  227. {
  228.    this.attachDebug();
  229.    this.sendClientEvent(new NetDebugCloseEvent());
  230.    if(this.isRealTime())
  231.    {
  232.       getNetDebug().sendCommand(new StopRTMPTraceCommand(this.m_ConnectString,this.m_ClientId));
  233.    }
  234.    var ret = this.realclose();
  235.    getNetDebug().removeNetConnection(this);
  236.    return ret;
  237. }
  238. function netDebugProxyAddHeader()
  239. {
  240.    this.attachDebug();
  241.    this.sendClientEvent(new NetDebugAddHeaderEvent(arguments));
  242.    return this.realaddHeader.apply(this,arguments);
  243. }
  244. function RTMPClientIDResponse(cs, nc)
  245. {
  246.    this.m_ConnectString = cs;
  247.    this.m_NC = nc;
  248. }
  249. function NetDebugResponseProxy(source, original)
  250. {
  251.    this.m_SourceNC = source;
  252.    this.m_OriginalNR = original;
  253. }
  254. function GlobalLocalConnection(iscontroller, receiver, domainname)
  255. {
  256.    this.maxConnections = 10;
  257.    var sToMovie = "_NetDebugLocalToDebugMovie";
  258.    var sToController = "_NetDebugLocalToController";
  259.    var connectname = null;
  260.    if(iscontroller)
  261.    {
  262.       connectname = sToController;
  263.       this.sendnames = new Array();
  264.       this.sendnames.push(sToMovie);
  265.       var i = 0;
  266.       while(i < this.maxConnections)
  267.       {
  268.          this.sendnames.push(sToMovie + i);
  269.          i++;
  270.       }
  271.       this.maxConnections = 0;
  272.    }
  273.    else
  274.    {
  275.       connectname = sToMovie;
  276.       this.sendnames = new Array();
  277.       this.sendnames.push(sToController);
  278.    }
  279.    this.setDomainName(domainname);
  280.    if(_global.g_NetDebugLocalConnection == undefined)
  281.    {
  282.       _global.g_NetDebugLocalConnection = new LocalConnection();
  283.       _global.g_NetDebugLocalConnection.allowDomain = function()
  284.       {
  285.          return true;
  286.       };
  287.    }
  288.    if(receiver != null)
  289.    {
  290.       _global.g_NetDebugLocalConnection.m_Receiver = receiver;
  291.       _global.g_NetDebugLocalConnection.onData = function(dataobj)
  292.       {
  293.          _global.g_NetDebugLocalConnection.m_Receiver.onReceive(dataobj);
  294.       };
  295.       _global.g_NetDebugLocalConnection.onCommand = function(commandobj)
  296.       {
  297.          _global.g_NetDebugLocalConnection.m_Receiver.onReceiveCommand(commandobj);
  298.       };
  299.       if(!_global.g_NetDebugLocalConnection.connect(connectname))
  300.       {
  301.          var connected = false;
  302.          var i = 0;
  303.          while(i < this.maxConnections)
  304.          {
  305.             if(_global.g_NetDebugLocalConnection.connect(connectname + i))
  306.             {
  307.                connected = true;
  308.                break;
  309.             }
  310.             i++;
  311.          }
  312.          if(!connected)
  313.          {
  314.             if(iscontroller)
  315.             {
  316.                receiver.onReceiveError(new NetDebugDuplicateNCDErrorEvent());
  317.             }
  318.          }
  319.       }
  320.    }
  321. }
  322. function LocalCommand()
  323. {
  324. }
  325. function UpdateNetDebugConfigCommand(dataobj)
  326. {
  327.    this.init("updateConfig",dataobj);
  328. }
  329. function GetConfigCommand()
  330. {
  331.    this.init("getConfig",null);
  332. }
  333. function StartRTMPTraceCommand(cs)
  334. {
  335.    var connectinfo = new Object();
  336.    connectinfo.connectstring = cs;
  337.    connectinfo.url = _root._url;
  338.    this.init("startRealTimeTrace",connectinfo);
  339. }
  340. function AddRTMPClientCommand(cs, cid)
  341. {
  342.    var connectinfo = new Object();
  343.    connectinfo.connectstring = cs;
  344.    connectinfo.url = _root._url;
  345.    connectinfo.clientid = cid;
  346.    this.init("addRealTimeClient",connectinfo);
  347. }
  348. function StopRTMPTraceCommand(cs, cid)
  349. {
  350.    var connectinfo = new Object();
  351.    connectinfo.connectstring = cs;
  352.    connectinfo.url = _root._url;
  353.    connectinfo.clientid = cid;
  354.    this.init("stopRealTimeTrace",connectinfo);
  355. }
  356. function NetDebug()
  357. {
  358.    this.m_ncs = new Array();
  359.    this.m_Config = getDefaultNetDebugConfig();
  360.    this.m_glc = new GlobalLocalConnection(false,this);
  361.    this.m_glc.sendCommand(new GetConfigCommand());
  362.    this.m_NextNewId = 0;
  363. }
  364. function getNetDebug()
  365. {
  366.    return _global.netDebugInstance;
  367. }
  368. function mAddGeneral(vSession, vPK, vStart, vEnd, vHeight, vWidth, vDepth, vPlatform)
  369. {
  370.    aRecord = new Object();
  371.    aRecord.session_ID = vSession;
  372.    aRecord.pk_ID = vPK;
  373.    aRecord.session_start = vStart;
  374.    aRecord.session_end = vEnd;
  375.    aRecord.screenheight = vHeight;
  376.    aRecord.screenwidth = vWidth;
  377.    aRecord.screendepth = vDepth;
  378.    aRecord.platform = vPlatform;
  379.    pGeneral_RS.push(aRecord);
  380. }
  381. function mAddSection(vMain, vFirst, vGallery, vSlideshow, vTrailer, vPoster, vLogos, vNotes, vSummary, vFlashpaper, vWebsite)
  382. {
  383.    aRecord = new Object();
  384.    aRecord.main = vMain;
  385.    aRecord.first = vFirst;
  386.    aRecord.gallery = vGallery;
  387.    aRecord.slideshow = vSlideshow;
  388.    aRecord.trailer = vTrailer;
  389.    aRecord.poster = vPoster;
  390.    aRecord.logos = vLogos;
  391.    aRecord.notes = vNotes;
  392.    aRecord.summary = vSummary;
  393.    aRecord.flashpaper = vFlashpaper;
  394.    aRecord.website = vWebsite;
  395.    pSections_RS.push(aRecord);
  396. }
  397. function mAddSuperSectionOLD()
  398. {
  399. }
  400. function mAddSuperSection(vMovieTitle, vView)
  401. {
  402.    aRecord = new Object();
  403.    aRecord.movietitle = vMovieTitle;
  404.    aRecord.viewdata = vView;
  405.    pSuperSections_RS.push(aRecord);
  406. }
  407. function mAddDownLoads(vType, vName)
  408. {
  409.    aRecord = new Object();
  410.    aRecord.type = vType;
  411.    aRecord.name = vName;
  412.    pDownLoads_RS.push(aRecord);
  413. }
  414. function mAddImages(vName)
  415. {
  416.    pImages_RS.push(vName);
  417. }
  418. function mAddFlashpaper(vName)
  419. {
  420.    pFlashpaper_RS.push(vName);
  421. }
  422. function mSendToColdFusion()
  423. {
  424.    pDebugResults = "";
  425.    exposure.inserttrackingdata(pGeneral_RS,pSections_RS,pDownLoads_RS,pImages_RS);
  426. }
  427. function mSendSuperToColdFusion()
  428. {
  429.    pDebugResults = "";
  430.    exposure.insertsupertrackingdata(pGeneral_RS,pSuperSections_RS,pDownLoads_RS,pImages_RS,pFlashpaper_RS);
  431. }
  432. function mSendToColdFusion_Result(data)
  433. {
  434.    trace("Data from mSendToColdFusion_Result : " + data);
  435. }
  436. function mSendSuperToColdFusion_Result(data)
  437. {
  438.    trace("Data from mSendSuperToColdFusion_Result : " + data);
  439. }
  440. function mSendNewToColdFusion_Result(data)
  441. {
  442.    trace("Data from mSendNewToColdFusion_Result : " + data);
  443. }
  444. function mSendNewToColdFusion()
  445. {
  446.    trace("FLASH: pGeneral_RS: " + pGeneral_RS.toString());
  447.    trace("FLASH: pSuperSections_RS: " + pSuperSections_RS.toString());
  448.    trace("FLASH: pDownLoads_RS: " + pDownLoads_RS.toString());
  449.    trace("FLASH: pImages_RS: " + pImages_RS.toString());
  450.    trace("FLASH: pFlashpaper_RS: " + pFlashpaper_RS.toString());
  451.    trace("FLASH: pSuperSections_RS[0]: " + this.pSuperSections_RS[0].movietitle.toString());
  452.    trace("FLASH: pSuperSections_RS[1]: " + this.pSuperSections_RS[1].movietitle.toString());
  453.    trace("FLASH: pSuperSections_RS[2]: " + this.pSuperSections_RS[2].movietitle.toString());
  454.    trace("FLASH: pSuperSections_RS[3]: " + this.pSuperSections_RS[3].movietitle.toString());
  455.    trace("FLASH: pSuperSections_RS[0]: " + this.pSuperSections_RS[0].viewdata.toString());
  456.    trace("FLASH: pSuperSections_RS[1]: " + this.pSuperSections_RS[1].viewdata.toString());
  457.    trace("FLASH: pSuperSections_RS[2]: " + this.pSuperSections_RS[2].viewdata.toString());
  458.    trace("FLASH: pSuperSections_RS[3]: " + this.pSuperSections_RS[3].viewdata.toString());
  459.    pDebugResults = "";
  460.    exposure.insertnewtrackingdata(pGeneral_RS,pSections_RS,pDownLoads_RS,pImages_RS,pFlashpaper_RS);
  461.    trace("FLASH: mSendNewToColdFusion executed");
  462. }
  463. function insertsupertrackingdata(result)
  464. {
  465.    trace("FLASH: Results from coldfusion insertsupertrackingdata: " + result);
  466.    pDebugResults = result;
  467. }
  468. function insertnewtrackingdata(result)
  469. {
  470.    trace("FLASH: Results from coldfusion insertnewtrackingdata: " + result);
  471.    pDebugResults = result;
  472. }
  473. function inserttrackingdata_Result(result)
  474. {
  475.    trace("FLASH: Results from coldfusion inserttrackingdata_Result: " + result);
  476.    pDebugResults = result;
  477. }
  478. function insertnewtrackingdata_Result(result)
  479. {
  480.    trace("FLASH: Results from coldfusion insertnewtrackingdata_Result: " + result);
  481.    pDebugResults = result;
  482. }
  483. function mReport()
  484. {
  485.    trace("FLASH: General RecordSet: " + pGeneral_RS.getColumnNames());
  486.    trace("FLASH: Sections RecordSet: " + pSections_RS.getColumnNames());
  487.    trace("FLASH: Super Sections RecordSet: " + pSuperSections_RS.getColumnNames());
  488.    trace("FLASH: DownLoads RecordSet: " + pDownLoads_RS.getColumnNames());
  489.    trace("FLASH: Images RecordSet: " + pImages_RS.getColumnNames());
  490.    trace("FLASH: Flashpaper RecordSet: " + pFlashpaper_RS.getColumnNames());
  491. }
  492. function mReSetArrays()
  493. {
  494.    pGeneral_RS = [];
  495.    pSections_RS = [];
  496.    pSuperSections_RS = [];
  497.    pDownLoads_RS = [];
  498.    pImages_RS = [];
  499.    pFlashpaper_RS = [];
  500.    trace("FLASH: Arrays have been reset: ");
  501. }
  502. stop();
  503. _global.copyProperties = function(to, from)
  504. {
  505.    for(var prop in from)
  506.    {
  507.       if(!(prop == "__proto__" || prop == "function"))
  508.       {
  509.          if(typeof from[prop] == "object")
  510.          {
  511.             if(to[prop] == undefined)
  512.             {
  513.                to[prop] = new from[prop].__proto__.constructor();
  514.             }
  515.             copyProperties(to[prop],from[prop]);
  516.          }
  517.          else
  518.          {
  519.             to[prop] = from[prop];
  520.          }
  521.       }
  522.    }
  523. };
  524. _global.copyObject = function(obj)
  525. {
  526.    if(typeof obj == "object")
  527.    {
  528.       var ret = new obj.__proto__.constructor();
  529.       copyProperties(ret,obj);
  530.       return ret;
  531.    }
  532.    return obj;
  533. };
  534. _global.objectToStringTree = function(obj, openstr, typesepstr, valuesepstr, closestr)
  535. {
  536.    var st = new StringLineAdder(obj,new TreeLineRenderer(openstr != null ? openstr : "{",typesepstr != null ? typesepstr : ":",valuesepstr != null ? valuesepstr : ", ",closestr != null ? closestr : "}"));
  537.    return st.getString();
  538. };
  539. _global.objectToListboxTree = function(listbox, obj, openstr, typesepstr, valuesepstr, closestr)
  540. {
  541.    new ListLineAdder(listbox,obj,new TreeLineRenderer(openstr != null ? openstr : "{",typesepstr != null ? typesepstr : ":",valuesepstr != null ? valuesepstr : ", ",closestr != null ? closestr : "}"));
  542. };
  543. _global.StringLineAdder = function(obj, renderer)
  544. {
  545.    this.linerenderer = renderer;
  546.    this.output = "";
  547.    nestedObjectDump(0,null,obj,this);
  548. };
  549. StringLineAdder.prototype.getString = function()
  550. {
  551.    return this.output;
  552. };
  553. StringLineAdder.prototype.addLine = function(level, objname, objtype, objvalue, objnum)
  554. {
  555.    var line = this.linerenderer.getLine(level,objname,objtype,objvalue,objnum);
  556.    if(line != null)
  557.    {
  558.       this.output += line + "\n";
  559.    }
  560.    return true;
  561. };
  562. _global.ListLineAdder = function(listbox, obj, renderer)
  563. {
  564.    this.linerenderer = renderer;
  565.    this.output_lb = listbox;
  566.    nestedObjectDump(0,null,obj,this);
  567. };
  568. ListLineAdder.prototype.addLine = function(level, objname, objtype, objvalue, objnum)
  569. {
  570.    var line = this.linerenderer.getLine(level,objname,objtype,objvalue,objnum);
  571.    if(line != null)
  572.    {
  573.       this.output_lb.addItem(line);
  574.    }
  575.    return true;
  576. };
  577. _global.TreeLineRenderer = function(pre, typedelim, valuedelim, post)
  578. {
  579.    this.init(pre,typedelim,valuedelim,post);
  580. };
  581. TreeLineRenderer.prototype.init = function(pre, typedelim, valuedelim, post)
  582. {
  583.    this.prechar = pre;
  584.    this.typechar = typedelim;
  585.    this.valuechar = valuedelim;
  586.    this.postchar = post;
  587. };
  588. TreeLineRenderer.prototype.getLine = function(level, objname, objtype, objvalue, objnum)
  589. {
  590.    var sAdd = "";
  591.    var i = 0;
  592.    while(i < level)
  593.    {
  594.       sAdd += "\t";
  595.       i++;
  596.    }
  597.    var valuedelim = this.valuechar;
  598.    if(objname != null && objtype != "object")
  599.    {
  600.       sAdd += this.prechar + objtype + this.typechar + objname;
  601.    }
  602.    else if(objtype == "object")
  603.    {
  604.       if(typeof objvalue == "number")
  605.       {
  606.          sAdd += this.prechar + objtype + this.typechar + objname;
  607.          sAdd += valuedelim + "object#" + objvalue;
  608.          objvalue = null;
  609.       }
  610.       else
  611.       {
  612.          sAdd += this.prechar + objtype + "#" + objnum + this.typechar + objname;
  613.       }
  614.    }
  615.    else
  616.    {
  617.       sAdd += this.prechar + objtype;
  618.       valuedelim = this.typechar;
  619.    }
  620.    if(objvalue != null)
  621.    {
  622.       sAdd += valuedelim + objvalue;
  623.    }
  624.    sAdd += this.postchar;
  625.    return sAdd;
  626. };
  627. _global.nestedObjectDump = function(level, objname, obj, lineadder)
  628. {
  629.    if(level == 0)
  630.    {
  631.       nestedObjectDump.callcount = nestedObjectDump.callcount + 1;
  632.       nestedObjectDump.objcount = -1;
  633.    }
  634.    if(obj == null)
  635.    {
  636.       return lineadder.addLine(level,objname,"undefined");
  637.    }
  638.    if(typeof obj == "function")
  639.    {
  640.       return lineadder.addLine(level,objname,"function");
  641.    }
  642.    if(typeof obj == "object")
  643.    {
  644.       if(obj.__nestedObjectDump_id != undefined && obj.__nestedObjectDump_ref == nestedObjectDump.callcount)
  645.       {
  646.          return lineadder.addLine(level,objname,"object",obj.__nestedObjectDump_id);
  647.       }
  648.       nestedObjectDump.objcount = nestedObjectDump.objcount + 1;
  649.       if(lineadder.addLine(level,objname,"object",null,nestedObjectDump.objcount) == nestedObjectDump.skip)
  650.       {
  651.          return nestedObjectDump.proceed;
  652.       }
  653.       obj.__nestedObjectDump_id = nestedObjectDump.objcount;
  654.       obj.__nestedObjectDump_ref = nestedObjectDump.callcount;
  655.       var props = new Array();
  656.       var objs = new Array();
  657.       for(var prop in obj)
  658.       {
  659.          if(!(prop == "__proto__" || prop == "__nestedObjectDump_id" || prop == "__nestedObjectDump_ref"))
  660.          {
  661.             if(typeof obj[prop] == "object")
  662.             {
  663.                objs.push(prop);
  664.             }
  665.             else
  666.             {
  667.                props.push(prop);
  668.             }
  669.          }
  670.       }
  671.       if(objs.length == 0 && props.length == 0)
  672.       {
  673.          if(typeof obj.toString == "function" && obj.toString() != "")
  674.          {
  675.             return lineadder.addLine(level + 1,null,"string",obj.toString());
  676.          }
  677.          if(lineadder.noProps != undefined)
  678.          {
  679.             lineadder.noProps(level + 1);
  680.             return nestedObjectDump.proceed;
  681.          }
  682.       }
  683.       props.sort();
  684.       objs.sort();
  685.       var bret = true;
  686.       var i = 0;
  687.       while(i < props.length)
  688.       {
  689.          if(nestedObjectDump(level + 1,props[i],obj[props[i]],lineadder) == nestedObjectDump.stop)
  690.          {
  691.             bret = false;
  692.             break;
  693.          }
  694.          i++;
  695.       }
  696.       if(bret)
  697.       {
  698.          var i = 0;
  699.          while(i < objs.length)
  700.          {
  701.             if(!nestedObjectDump(level + 1,objs[i],obj[objs[i]],lineadder))
  702.             {
  703.                bret = false;
  704.             }
  705.             i++;
  706.          }
  707.       }
  708.       return nestedObjectDump.proceed;
  709.    }
  710.    return lineadder.addLine(level,objname,typeof obj,obj);
  711. };
  712. nestedObjectDump.proceed = 1;
  713. nestedObjectDump.skip = 2;
  714. nestedObjectDump.stop = 3;
  715. nestedObjectDump.callcount = 0;
  716. nestedObjectDump.objcount = 0;
  717. Object.registerClass("NetDebugConfig",NetDebugConfig);
  718. NetDebugEvent.prototype.init = function()
  719. {
  720.    this.EventType = "DebugEvent";
  721.    this.Source = "Client";
  722.    this.MovieUrl = unescape(_root._url);
  723.    this.initDate();
  724. };
  725. NetDebugEvent.prototype.initDate = function()
  726. {
  727.    var now = new Date();
  728.    this.Date = now;
  729.    this.Time = now.getTime();
  730. };
  731. NetDebugErrorEvent.prototype = new NetDebugEvent();
  732. NetDebugTraceEvent.prototype = new NetDebugEvent();
  733. NetDebugTraceNetServicesEvent.prototype = new NetDebugEvent();
  734. NetDebugNCEvent.prototype = new NetDebugEvent();
  735. NetDebugResultEvent.prototype = new NetDebugNCEvent();
  736. NetDebugStatusEvent.prototype = new NetDebugNCEvent();
  737. NetDebugConnectEvent.prototype = new NetDebugNCEvent();
  738. NetDebugCallEvent.prototype = new NetDebugNCEvent();
  739. NetDebugCloseEvent.prototype = new NetDebugNCEvent();
  740. NetDebugAddHeaderEvent.prototype = new NetDebugNCEvent();
  741. NetDebugRtmpLogEvent.prototype = new NetDebugNCEvent();
  742. NetDebugDuplicateNCDErrorEvent.prototype = new NetDebugNCEvent();
  743. NetDebugFailedSendErrorEvent.prototype = new NetDebugNCEvent();
  744. NetDebugInfoErrorEvent.prototype = new NetDebugNCEvent();
  745. NetDebugResultEvent.prototype = new NetDebugNCEvent();
  746. _global.StripNCDEventToMinmal = function(ev)
  747. {
  748.    var ret = new Object();
  749.    if(ev.EventType != null)
  750.    {
  751.       ret.EventType = ev.EventType;
  752.    }
  753.    if(ev.Source != null)
  754.    {
  755.       ret.Source = ev.Source;
  756.    }
  757.    if(ev.MovieUrl != null)
  758.    {
  759.       ret.MovieUrl = ev.MovieUrl;
  760.    }
  761.    if(ev.Date != null)
  762.    {
  763.       ret.Date = ev.Date;
  764.    }
  765.    if(ev.Time != null)
  766.    {
  767.       ret.Time = ev.Time;
  768.    }
  769.    if(ev.Protocol != null)
  770.    {
  771.       ret.Protocol = ev.Protocol;
  772.    }
  773.    if(ev.DebugId != null)
  774.    {
  775.       ret.DebugId = ev.DebugId;
  776.    }
  777.    return ret;
  778. };
  779. NetConnection.prototype.attachDebug = function()
  780. {
  781.    if(!this.m_Attached)
  782.    {
  783.       this.m_Attached = true;
  784.       this.m_HeaderAdded = false;
  785.       this.m_Config = new NetDebugConfig();
  786.       copyProperties(this.m_Config,getNetDebug().m_Config);
  787.       this.m_Protocol = "none";
  788.       this.m_Id = getNetDebug().addNetConnection(this);
  789.    }
  790. };
  791. NetConnection.prototype.sendDebugEvent = function(eventobj)
  792. {
  793.    eventobj.Protocol = this.m_Protocol;
  794.    eventobj.DebugId = this.m_Id;
  795.    return getNetDebug().onEvent(eventobj);
  796. };
  797. NetConnection.prototype.sendServerEvent = function(eventobj)
  798. {
  799.    eventobj.MovieUrl = unescape(_root._url);
  800.    if(this.sendDebugEvent(eventobj))
  801.    {
  802.    }
  803. };
  804. NetConnection.prototype.sendClientEvent = function(eventobj)
  805. {
  806.    if(this.m_Config.m_debug && this.m_Config.client.m_debug)
  807.    {
  808.       if(this.m_Config.client.http && this.m_Protocol == "http" || this.m_Config.client.rtmp && this.m_Protocol == "rtmp")
  809.       {
  810.          if(this.sendDebugEvent(eventobj))
  811.          {
  812.          }
  813.       }
  814.    }
  815. };
  816. NetConnection.prototype.addNetDebugHeader = function()
  817. {
  818.    if(!this.m_HeaderAdded)
  819.    {
  820.       this.m_HeaderAdded = true;
  821.       if(this.m_Config.m_debug && this.m_Config.app_server.m_debug && this.m_Protocol == "http")
  822.       {
  823.          this.realaddHeader("amf_server_debug",true,this.m_Config.app_server);
  824.       }
  825.       else
  826.       {
  827.          this.realaddHeader("amf_server_debug",true,undefined);
  828.       }
  829.    }
  830. };
  831. NetConnection.prototype.updateConfig = function(config)
  832. {
  833.    this.attachDebug();
  834.    copyProperties(this.m_Config,config);
  835.    this.m_HeaderAdded = false;
  836. };
  837. NetConnection.prototype.isRealTime = function()
  838. {
  839.    return this.m_Protocol == "rtmp";
  840. };
  841. NetConnection.prototype.setupRecordset = function()
  842. {
  843.    this.attachDebug();
  844.    this.m_Config.client.http = this.m_Config.client.recordset;
  845. };
  846. NetConnection.prototype.setDebugId = function(id)
  847. {
  848.    this.attachDebug();
  849.    this.m_Id = id;
  850. };
  851. NetConnection.prototype.getDebugId = function()
  852. {
  853.    this.attachDebug();
  854.    return this.m_Id;
  855. };
  856. NetConnection.prototype.trace = function(traceobj)
  857. {
  858.    this.attachDebug();
  859.    if(this.m_Config.m_debug && this.m_Config.client.m_debug && this.m_Config.client.trace)
  860.    {
  861.       this.sendDebugEvent(new NetDebugTraceEvent(traceobj));
  862.    }
  863. };
  864. NetConnection.prototype.getDebugConfig = function()
  865. {
  866.    this.attachDebug();
  867.    return this.m_Config;
  868. };
  869. if(!NetConnection.prototype.netDebugProxyFunctions)
  870. {
  871.    NetConnection.prototype.netDebugProxyFunctions = true;
  872.    NetConnection.prototype.realconnect = NetConnection.prototype.connect;
  873.    NetConnection.prototype.realcall = NetConnection.prototype.call;
  874.    NetConnection.prototype.realclose = NetConnection.prototype.close;
  875.    NetConnection.prototype.realaddHeader = NetConnection.prototype.addHeader;
  876.    NetConnection.prototype.connect = netDebugProxyConnect;
  877.    NetConnection.prototype.call = netDebugproxyCall;
  878.    NetConnection.prototype.close = netDebugproxyClose;
  879.    NetConnection.prototype.addHeader = netDebugproxyAddHeader;
  880. }
  881. RTMPClientIDResponse.prototype.onResult = function(cid)
  882. {
  883.    this.m_NC.m_ClientId = cid;
  884.    getNetDebug().sendCommand(new AddRTMPClientCommand(this.m_ConnectString,cid));
  885. };
  886. NetDebugResponseProxy.prototype.onDebugEvents = function(debugevents)
  887. {
  888.    var i = 0;
  889.    while(i < debugevents.length)
  890.    {
  891.       this.m_SourceNC.sendServerEvent(debugevents[i]);
  892.       i++;
  893.    }
  894. };
  895. NetDebugResponseProxy.prototype.onResult = function(resultobj)
  896. {
  897.    this.m_SourceNC.sendClientEvent(new NetDebugResultEvent(resultobj));
  898.    this.m_OriginalNR.onResult(resultobj);
  899. };
  900. NetDebugResponseProxy.prototype.onStatus = function(statusobj)
  901. {
  902.    this.m_SourceNC.sendClientEvent(new NetDebugStatusEvent(statusobj));
  903.    if(this.m_OriginalNR.onStatus != undefined)
  904.    {
  905.       this.m_OriginalNR.onStatus(statusobj);
  906.    }
  907.    else
  908.    {
  909.       _global.System.onStatus(statusobj);
  910.    }
  911. };
  912. NetDebugResponseProxy.prototype.__resolve = function(name)
  913. {
  914.    this.m_SourceNC.sendClientEvent(new NetDebugReceiveCallEvent(name,arguments));
  915.    this.m_OriginalNR[name].apply(arguments);
  916. };
  917. GlobalLocalConnection.prototype.setDomainName = function(domainname)
  918. {
  919.    if(domainname != null && domainname != "")
  920.    {
  921.       this.sendPrefix = domainname + ":";
  922.    }
  923.    else
  924.    {
  925.       this.sendPrefix = "";
  926.    }
  927. };
  928. GlobalLocalConnection.prototype.send = function(dataobj)
  929. {
  930.    return this.sendRaw("onData",dataobj);
  931. };
  932. GlobalLocalConnection.prototype.sendCommand = function(commandobj)
  933. {
  934.    return this.sendRaw("onCommand",commandobj);
  935. };
  936. GlobalLocalConnection.prototype.sendRaw = function(functionname, obj)
  937. {
  938.    var suc = true;
  939.    var i = 0;
  940.    while(i < this.sendnames.length)
  941.    {
  942.       suc &= _global.g_NetDebugLocalConnection.send(this.sendPrefix + this.sendnames[i],functionname,obj);
  943.       i++;
  944.    }
  945.    return suc;
  946. };
  947. LocalCommand.prototype.init = function(commandname, dataobj)
  948. {
  949.    this.command = commandname;
  950.    this.data = dataobj;
  951. };
  952. UpdateNetDebugConfigCommand.prototype = new LocalCommand();
  953. GetConfigCommand.prototype = new LocalCommand();
  954. StartRTMPTraceCommand.prototype = new LocalCommand();
  955. AddRTMPClientCommand.prototype = new LocalCommand();
  956. StopRTMPTraceCommand.prototype = new LocalCommand();
  957. NetDebug.prototype.addNetConnection = function(nc)
  958. {
  959.    this.m_ncs.push(nc);
  960.    return this.m_NextNewId++;
  961. };
  962. NetDebug.prototype.removeNetConnection = function(nc)
  963. {
  964.    var i = 0;
  965.    while(i < this.m_ncs.length)
  966.    {
  967.       if(nc == this.m_ncs[i])
  968.       {
  969.          this.m_ncs.splice(i,1);
  970.          break;
  971.       }
  972.       i++;
  973.    }
  974. };
  975. NetDebug.prototype.sendDebugEvent = function(eventobj)
  976. {
  977.    if(!this.m_glc.send(eventobj))
  978.    {
  979.       this.m_glc.send(new NetDebugFailedSendErrorEvent(StripNCDEventToMinmal(eventobj)));
  980.       return false;
  981.    }
  982.    return true;
  983. };
  984. NetDebug.prototype.sendCommand = function(commandobj)
  985. {
  986.    return this.m_glc.sendCommand(commandobj);
  987. };
  988. NetDebug.prototype.requestNewConfig = function()
  989. {
  990.    return this.sendCommand(new GetConfigCommand());
  991. };
  992. NetDebug.prototype.updateConfig = function(config)
  993. {
  994.    copyProperties(this.m_Config,config);
  995.    var i = 0;
  996.    while(i < this.m_ncs.length)
  997.    {
  998.       if(this.m_ncs[i] != null)
  999.       {
  1000.          this.m_ncs[i].updateConfig(config);
  1001.       }
  1002.       i++;
  1003.    }
  1004. };
  1005. NetDebug.prototype.sendStatus = function(statusobj)
  1006. {
  1007.    if(this.m_Config.m_debug && this.m_Config.client.m_debug)
  1008.    {
  1009.       return this.m_glc.send(new NetDebugStatusEvent(statusobj));
  1010.    }
  1011. };
  1012. NetDebug.prototype.onEvent = function(eventobj)
  1013. {
  1014.    return this.sendDebugEvent(eventobj);
  1015. };
  1016. NetDebug.prototype.onEventError = function(errorobj)
  1017. {
  1018.    return this.sendDebugEvent(new NetDebugErrorEvent(errorobj));
  1019. };
  1020. NetDebug.prototype.onReceiveCommand = function(commandobj)
  1021. {
  1022.    this[commandobj.command](commandobj.data);
  1023. };
  1024. NetDebug.prototype.onReceiveError = function(errorobj)
  1025. {
  1026.    this.sendDebugEvent(new NetDebugErrorEvent(errorobj));
  1027. };
  1028. NetDebug.prototype.traceNetServices = function(who, severity, number, message)
  1029. {
  1030.    if(this.m_Config.m_debug && this.m_Config.client.m_debug && this.m_Config.client.trace)
  1031.    {
  1032.       if(this.sendDebugEvent(new NetDebugTraceNetServicesEvent(who,severity,number,message)))
  1033.       {
  1034.       }
  1035.    }
  1036. };
  1037. NetDebug.prototype.trace = function(traceobj)
  1038. {
  1039.    if(this.m_Config.m_debug && this.m_Config.client.m_debug && this.m_Config.client.trace)
  1040.    {
  1041.       if(this.sendDebugEvent(new NetDebugTraceEvent(traceobj)))
  1042.       {
  1043.       }
  1044.    }
  1045. };
  1046. if(_global.netDebugInstance == undefined)
  1047. {
  1048.    _global.netDebugInstance = new NetDebug();
  1049. }
  1050. NetDebug.trace = function(obj)
  1051. {
  1052.    getNetDebug().trace(obj);
  1053. };
  1054. NetDebug.traceNetServices = function(who, severity, number, message)
  1055. {
  1056.    getNetDebug().traceNetServices(who,severity,number,message);
  1057. };
  1058. NetDebug.getVersion = function()
  1059. {
  1060.    return getNetDebugVersion();
  1061. };
  1062. NetDebug.globalOnStatus = function(statusobj)
  1063. {
  1064.    getNetDebug().sendStatus(statusobj);
  1065. };
  1066. if(_global.System.onStatus == undefined)
  1067. {
  1068.    _global.System.onStatus = NetDebug.globalOnStatus;
  1069. }
  1070. _global.RsDataProviderClass = function()
  1071. {
  1072.    this.init();
  1073. };
  1074. RsDataProviderClass.prototype.init = function()
  1075. {
  1076.    this.items = new Array();
  1077.    this.uniqueID = 0;
  1078.    this.views = new Array();
  1079. };
  1080. RsDataProviderClass.prototype.addView = function(viewRef)
  1081. {
  1082.    this.views.push(viewRef);
  1083.    var eventObj = {event:"updateAll"};
  1084.    viewRef.modelChanged(eventObj);
  1085. };
  1086. RsDataProviderClass.prototype.addItemAt = function(index, value)
  1087. {
  1088.    if(!this.checkLocal())
  1089.    {
  1090.       return undefined;
  1091.    }
  1092.    if(index < 0)
  1093.    {
  1094.       return undefined;
  1095.    }
  1096.    if(index < this.getLength())
  1097.    {
  1098.       this.items.splice(index,0,"tmp");
  1099.    }
  1100.    this.items[index] = new Object();
  1101.    if(typeof value == "object")
  1102.    {
  1103.       this.items[index] = value;
  1104.    }
  1105.    this.items[index].__ID__ = this.uniqueID++;
  1106.    var eventObj = {event:"addRows",firstRow:index,lastRow:index};
  1107.    this.updateViews(eventObj);
  1108. };
  1109. RsDataProviderClass.prototype.addItem = function(value)
  1110. {
  1111.    if(!this.checkLocal())
  1112.    {
  1113.       return undefined;
  1114.    }
  1115.    this.addItemAt(this.getLength(),value);
  1116. };
  1117. RsDataProviderClass.prototype.removeItemAt = function(index)
  1118. {
  1119.    if(!this.checkLocal())
  1120.    {
  1121.       return undefined;
  1122.    }
  1123.    if(index < 0 || index >= this.getLength())
  1124.    {
  1125.       return undefined;
  1126.    }
  1127.    var tmpItm = this.items[index];
  1128.    this.items.splice(index,1);
  1129.    var eventObj = {event:"deleteRows",firstRow:index,lastRow:index};
  1130.    this.updateViews(eventObj);
  1131.    return tmpItm;
  1132. };
  1133. RsDataProviderClass.prototype.removeAll = function()
  1134. {
  1135.    if(!this.checkLocal())
  1136.    {
  1137.       return undefined;
  1138.    }
  1139.    this.items = new Array();
  1140.    this.updateViews({event:"deleteRows",firstRow:0,lastRow:this.getLength() - 1});
  1141. };
  1142. RsDataProviderClass.prototype.replaceItemAt = function(index, itemObj)
  1143. {
  1144.    if(!this.checkLocal())
  1145.    {
  1146.       return undefined;
  1147.    }
  1148.    if(index < 0 || index >= this.getLength())
  1149.    {
  1150.       return undefined;
  1151.    }
  1152.    var tmpID = this.getItemID(index);
  1153.    this.items[index] = itemObj;
  1154.    this.items[index].__ID__ = tmpID;
  1155.    this.updateViews({event:"updateRows",firstRow:index,lastRow:index});
  1156. };
  1157. RsDataProviderClass.prototype.getLength = function()
  1158. {
  1159.    return this.items.length;
  1160. };
  1161. RsDataProviderClass.prototype.getItemAt = function(index)
  1162. {
  1163.    return this.items[index];
  1164. };
  1165. RsDataProviderClass.prototype.getItemID = function(index)
  1166. {
  1167.    return this.items[index].__ID__;
  1168. };
  1169. RsDataProviderClass.prototype.sortItemsBy = function(fieldName, order)
  1170. {
  1171.    if(!this.checkLocal())
  1172.    {
  1173.       return undefined;
  1174.    }
  1175.    this.items.sortOn(fieldName);
  1176.    if(order == "DESC")
  1177.    {
  1178.       this.items.reverse();
  1179.    }
  1180.    this.updateViews({event:"sort"});
  1181. };
  1182. RsDataProviderClass.prototype.updateViews = function(eventObj)
  1183. {
  1184.    var i = 0;
  1185.    while(i < this.views.length)
  1186.    {
  1187.       this.views[i].modelChanged(eventObj);
  1188.       i++;
  1189.    }
  1190. };
  1191. _global.RecordSet = function(columnNames)
  1192. {
  1193.    if(this.mTitles != null)
  1194.    {
  1195.       this.views = new Array();
  1196.       return undefined;
  1197.    }
  1198.    this.init();
  1199.    if(this.serverInfo == null)
  1200.    {
  1201.       this.mTitles = columnNames;
  1202.       return undefined;
  1203.    }
  1204.    if(this.serverInfo.version != 1)
  1205.    {
  1206.       NetServices.trace("RecordSet","warning",100,"Received incompatible recordset version from server");
  1207.       return undefined;
  1208.    }
  1209.    this.mTitles = this.serverInfo.columnNames;
  1210.    this.mRecordsAvailable = 0;
  1211.    this.setData(this.serverInfo.cursor != null ? this.serverInfo.cursor - 1 : 0,this.serverInfo.initialData);
  1212.    if(this.serverInfo.initialData.length != this.serverInfo.totalCount)
  1213.    {
  1214.       this.mRecordSetId = this.serverInfo.id;
  1215.       if(this.mRecordSetId != null)
  1216.       {
  1217.          this.serviceName = this.serverInfo.serviceName != null ? this.serverInfo.serviceName : "RecordSet";
  1218.          this.mTotalCount = this.serverInfo.totalCount;
  1219.          this.mDeliveryMode = "ondemand";
  1220.          this.mAllNotified = false;
  1221.          this.mOutstandingRecordCount = 0;
  1222.       }
  1223.       else
  1224.       {
  1225.          NetServices.trace("RecordSet","warning",102,"Missing some records, but there\'s no recordset id");
  1226.       }
  1227.    }
  1228.    this.serverInfo = null;
  1229. };
  1230. RecordSet.prototype = new RsDataProviderClass();
  1231. Object.registerClass("RecordSet",RecordSet);
  1232. RecordSet.prototype._setParentService = function(service)
  1233. {
  1234.    this.gateway_conn = service.nc;
  1235. };
  1236. RecordSet.prototype.getRecordSetService = function()
  1237. {
  1238.    if(this.mRecordSetService == null)
  1239.    {
  1240.       if(this.gateway_conn == null)
  1241.       {
  1242.          this.gateway_conn = NetServices.createGatewayConnection();
  1243.       }
  1244.       else if(_global.netDebugInstance != undefined)
  1245.       {
  1246.          this.gateway_conn = this.gateway_conn.clone();
  1247.       }
  1248.       if(_global.netDebugInstance != undefined)
  1249.       {
  1250.          this.gateway_conn.setupRecordset();
  1251.          this.gateway_conn.setDebugId("RecordSet " + this.mRecordSetId);
  1252.       }
  1253.       this.mRecordSetService = this.gateway_conn.getService(this.serviceName,this);
  1254.       if(this.mRecordSetService == null)
  1255.       {
  1256.          NetServices.trace("RecordSet","warning",101,"Failed to create recordset service");
  1257.          this.mRecordSetService = 0;
  1258.       }
  1259.    }
  1260.    return this.mRecordSetService;
  1261. };
  1262. RecordSet.prototype.getColumnNames = function()
  1263. {
  1264.    return this.mTitles;
  1265. };
  1266. RecordSet.prototype.getLength = function()
  1267. {
  1268.    if(this.mRecordSetID != null)
  1269.    {
  1270.       return this.mTotalCount;
  1271.    }
  1272.    return this.items.length;
  1273. };
  1274. RecordSet.prototype.getItemAt = function(index)
  1275. {
  1276.    if(this.mRecordSetId == null)
  1277.    {
  1278.       return this.items[index];
  1279.    }
  1280.    if(index < 0 || index >= this.getLength())
  1281.    {
  1282.       NetServices.trace("RecordSet","warning",104,"getItemAt(" + index + ") index out of range");
  1283.       return null;
  1284.    }
  1285.    this.requestRecord(index);
  1286.    var result = this.items[index];
  1287.    if(result == 1)
  1288.    {
  1289.       return "in progress";
  1290.    }
  1291.    return result;
  1292. };
  1293. RecordSet.prototype.setField = function(index, fieldName, value)
  1294. {
  1295.    if(!this.checkLocal())
  1296.    {
  1297.       return undefined;
  1298.    }
  1299.    if(index < 0 || index >= this.getLength())
  1300.    {
  1301.       return undefined;
  1302.    }
  1303.    this.items[index][fieldName] = value;
  1304.    this.updateViews({event:"updateRows",firstRow:index,lastRow:index});
  1305. };
  1306. RecordSet.prototype.filter = function(filterFunction, context)
  1307. {
  1308.    if(!this.checkLocal())
  1309.    {
  1310.       return undefined;
  1311.    }
  1312.    var result = new RecordSet(this.mTitles);
  1313.    var i = 0;
  1314.    while(i < this.getLength())
  1315.    {
  1316.       var item = this.getItemAt(i);
  1317.       if(item != null && item != 1 && filterFunction(item,context))
  1318.       {
  1319.          result.addItem(item);
  1320.       }
  1321.       i++;
  1322.    }
  1323.    return result;
  1324. };
  1325. RecordSet.prototype.sort = function(compareFunc)
  1326. {
  1327.    if(!this.checkLocal())
  1328.    {
  1329.       return undefined;
  1330.    }
  1331.    this.items.sort(compareFunc);
  1332.    this.updateViews({event:"sort"});
  1333. };
  1334. RecordSet.prototype.isLocal = function()
  1335. {
  1336.    return this.mRecordSetID == null;
  1337. };
  1338. RecordSet.prototype.isFullyPopulated = function()
  1339. {
  1340.    return this.isLocal();
  1341. };
  1342. RecordSet.prototype.getNumberAvailable = function()
  1343. {
  1344.    if(this.isLocal())
  1345.    {
  1346.       return this.getLength();
  1347.    }
  1348.    return this.mRecordsAvailable;
  1349. };
  1350. RecordSet.prototype.setDeliveryMode = function(mode, pagesize, numPrefetchPages)
  1351. {
  1352.    this.mDeliveryMode = mode;
  1353.    this.stopFetchAll();
  1354.    if(mode == "ondemand")
  1355.    {
  1356.       return undefined;
  1357.    }
  1358.    if(pagesize == null)
  1359.    {
  1360.       pagesize = this.views[0].getRowCount();
  1361.       if(pagesize == null)
  1362.       {
  1363.          pagesize = 25;
  1364.       }
  1365.    }
  1366.    if(mode == "page")
  1367.    {
  1368.       if(numPrefetchPages == null)
  1369.       {
  1370.          numPrefetchPages = 0;
  1371.       }
  1372.       this.mPageSize = pagesize;
  1373.       this.mNumPrefetchPages = numPrefetchPages;
  1374.    }
  1375.    else if(mode == "fetchall")
  1376.    {
  1377.       this.stopFetchAll();
  1378.       this.startFetchAll(pagesize);
  1379.    }
  1380.    else
  1381.    {
  1382.       NetServices.trace("RecordSet","warning",107,"SetDeliveryMode: unknown mode string");
  1383.    }
  1384. };
  1385. RecordSet.prototype.getRecords_Result = function(info)
  1386. {
  1387.    this.setData(info.Cursor - 1,info.Page);
  1388.    this.mOutstandingRecordCount -= info.Page.length;
  1389.    this.updateViews({event:"updateRows",firstRow:info.Cursor - 1,lastRow:info.Cursor - 1 + info.Page.length - 1});
  1390.    if(this.mRecordsAvailable == this.mTotalCount && !this.mAllNotified)
  1391.    {
  1392.       this.updateViews({event:"allRows"});
  1393.       this.mRecordSetService.release();
  1394.       this.mAllNotified = true;
  1395.       this.mRecordSetID = null;
  1396.       this.mRecordSetService = null;
  1397.    }
  1398. };
  1399. RecordSet.prototype.release_Result = function()
  1400. {
  1401. };
  1402. RecordSet.prototype.arrayToObject = function(anArray)
  1403. {
  1404.    if(this.mTitles == null)
  1405.    {
  1406.       NetServices.trace("RecordSet","warning",105,"getItem: titles are not available");
  1407.       return null;
  1408.    }
  1409.    var result = new Object();
  1410.    var i = 0;
  1411.    while(i < anArray.length)
  1412.    {
  1413.       var title = this.mTitles[i];
  1414.       if(title == null)
  1415.       {
  1416.          title = "column" + i + 1;
  1417.       }
  1418.       result[title] = anArray[i];
  1419.       i++;
  1420.    }
  1421.    return result;
  1422. };
  1423. RecordSet.prototype.setData = function(start, dataArray)
  1424. {
  1425.    var i = 0;
  1426.    while(i < dataArray.length)
  1427.    {
  1428.       var index = i + start;
  1429.       var rec = this.items[index];
  1430.       if(rec != null && rec != 1)
  1431.       {
  1432.          NetServices.trace("RecordSet","warning",106,"Already got record # " + recordIndex);
  1433.       }
  1434.       else
  1435.       {
  1436.          this.mRecordsAvailable += 1;
  1437.       }
  1438.       this.items[index] = this.arrayToObject(dataArray[i]);
  1439.       this.items[index].__ID__ = this.uniqueID++;
  1440.       i++;
  1441.    }
  1442. };
  1443. RecordSet.prototype.requestOneRecord = function(index)
  1444. {
  1445.    if(this.items[index] == null)
  1446.    {
  1447.       this.getRecordSetService().getRecords(this.mRecordSetId,index + 1,1);
  1448.       this.mOutstandingRecordCount = this.mOutstandingRecordCount + 1;
  1449.       this.items[index] = 1;
  1450.       this.updateViews({event:"fetchRows",firstRow:index,lastRow:index});
  1451.    }
  1452. };
  1453. RecordSet.prototype.requestRecord = function(index)
  1454. {
  1455.    if(this.mDeliveryMode != "page")
  1456.    {
  1457.       this.requestOneRecord(index);
  1458.       return undefined;
  1459.    }
  1460.    var firstIndex = int(index / this.mPageSize) * this.mPageSize;
  1461.    var lastIndex = firstIndex + this.mPageSize * (this.mNumPrefetchPages + 1) - 1;
  1462.    this.requestRecordRange(firstIndex,lastIndex);
  1463. };
  1464. RecordSet.prototype.requestRecordRange = function(index, lastIndex)
  1465. {
  1466.    var highestRequested = -1;
  1467.    if(index < 0)
  1468.    {
  1469.       index = 0;
  1470.    }
  1471.    if(lastIndex >= this.getLength())
  1472.    {
  1473.       lastIndex = this.getLength() - 1;
  1474.    }
  1475.    while(index <= lastIndex)
  1476.    {
  1477.       while(index <= lastIndex && this.items[index] != null)
  1478.       {
  1479.          index++;
  1480.       }
  1481.       var first = index;
  1482.       while(index <= lastIndex && this.items[index] == null)
  1483.       {
  1484.          this.mOutstandingRecordCount = this.mOutstandingRecordCount + 1;
  1485.          this.items[index] = 1;
  1486.          index++;
  1487.       }
  1488.       var last = index - 1;
  1489.       if(first <= last)
  1490.       {
  1491.          this.getRecordSetService().getRecords(this.mRecordSetId,first + 1,last - first + 1);
  1492.          highestRequested = last;
  1493.          this.updateViews({event:"fetchRows",firstRow:first,lastRow:last});
  1494.       }
  1495.    }
  1496.    return highestRequested;
  1497. };
  1498. RecordSet.prototype.startFetchAll = function(pagesize)
  1499. {
  1500.    this.mDataFetcher.disable();
  1501.    this.mDataFetcher = new RsDataFetcher(this,pagesize);
  1502. };
  1503. RecordSet.prototype.stopFetchAll = function()
  1504. {
  1505.    this.mDataFetcher.disable();
  1506.    this.mDataFetcher = null;
  1507. };
  1508. RecordSet.prototype.checkLocal = function()
  1509. {
  1510.    if(this.isLocal())
  1511.    {
  1512.       return true;
  1513.    }
  1514.    NetServices.trace("RecordSet","warning",108,"Operation not allowed on partial recordset");
  1515.    return false;
  1516. };
  1517. _global.RsDataFetcher = function(recordSet, increment)
  1518. {
  1519.    this.mRecordSet = recordSet;
  1520.    this.mRecordSet.addView(this);
  1521.    this.mIncrement = increment;
  1522.    this.mNextRecord = 0;
  1523.    this.mEnabled = true;
  1524.    this.doNext();
  1525. };
  1526. RsDataFetcher.prototype.disable = function()
  1527. {
  1528.    this.mEnabled = false;
  1529.    this.mRecordSet.removeView(this);
  1530. };
  1531. RsDataFetcher.prototype.doNext = function()
  1532. {
  1533.    if(!this.mEnabled)
  1534.    {
  1535.       return undefined;
  1536.    }
  1537.    while(true)
  1538.    {
  1539.       if(this.mNextRecord >= this.mRecordSet.getLength())
  1540.       {
  1541.          return undefined;
  1542.       }
  1543.       this.mHighestRequested = this.mRecordSet.requestRecordRange(this.mNextRecord,this.mNextRecord + this.mIncrement - 1);
  1544.       this.mNextRecord += this.mIncrement;
  1545.       if(this.mHighestRequested > 0)
  1546.       {
  1547.          return undefined;
  1548.       }
  1549.    }
  1550. };
  1551. RsDataFetcher.prototype.modelChanged = function(eventObj)
  1552. {
  1553.    if(eventObj.event == "updateRows" && eventObj.firstRow <= this.mHighestRequested && eventObj.lastRow >= this.mHighestRequested)
  1554.    {
  1555.       this.doNext();
  1556.    }
  1557.    if(eventObj.event == "allRows")
  1558.    {
  1559.       this.disable();
  1560.    }
  1561. };
  1562. _global.NetServiceProxyResponder = function(service, methodName)
  1563. {
  1564.    this.service = service;
  1565.    this.methodName = methodName;
  1566. };
  1567. NetServiceProxyResponder.prototype.onResult = function(result)
  1568. {
  1569.    var client = this.service.client;
  1570.    result._setParentService(this.service);
  1571.    var func = this.methodName + "_Result";
  1572.    if(typeof client[func] == "function")
  1573.    {
  1574.       client[func](result);
  1575.    }
  1576.    else if(typeof client.onResult == "function")
  1577.    {
  1578.       client.onResult(result);
  1579.    }
  1580.    else
  1581.    {
  1582.       NetServices.trace("NetServices","info",1,func + " was received from server: " + result);
  1583.    }
  1584. };
  1585. NetServiceProxyResponder.prototype.onStatus = function(result)
  1586. {
  1587.    var client = this.service.client;
  1588.    var func = this.methodName + "_Status";
  1589.    if(typeof client[func] == "function")
  1590.    {
  1591.       client[func](result);
  1592.    }
  1593.    else if(typeof client.onStatus == "function")
  1594.    {
  1595.       client.onStatus(result);
  1596.    }
  1597.    else if(typeof _root.onStatus == "function")
  1598.    {
  1599.       _root.onStatus(result);
  1600.    }
  1601.    else if(typeof _global.System.onStatus == "function")
  1602.    {
  1603.       _global.System.onStatus(result);
  1604.    }
  1605.    else
  1606.    {
  1607.       NetServices.trace("NetServices","info",2,func + " was received from server: " + result["class"] + " " + result.description);
  1608.    }
  1609. };
  1610. Object.registerClass("NetServiceProxy",NetServiceProxy);
  1611. _global.NetServiceProxy = function(nc, serviceName, client)
  1612. {
  1613.    if(nc != null)
  1614.    {
  1615.       this.nc = nc;
  1616.       this.serviceName = serviceName;
  1617.       this.client = client;
  1618.    }
  1619. };
  1620. NetServiceProxy.prototype._setParentService = function(service)
  1621. {
  1622.    this.nc = service.nc;
  1623.    this.client = service.client;
  1624. };
  1625. NetServiceProxy.prototype.__resolve = function(methodName)
  1626. {
  1627.    var f = function()
  1628.    {
  1629.       if(this.client != null)
  1630.       {
  1631.          arguments.unshift(new NetServiceProxyResponder(this,methodName));
  1632.       }
  1633.       else if(typeof arguments[0].onResult != "function")
  1634.       {
  1635.          NetServices.trace("NetServices","warning",3,"There is no defaultResponder, but no responder was given in call to " + methodName);
  1636.          arguments.unshift(new NetServiceProxyResponder(this,methodName));
  1637.       }
  1638.       arguments.unshift(this.serviceName + "." + methodName);
  1639.       return this.nc.call.apply(this.nc,arguments);
  1640.    };
  1641.    return f;
  1642. };
  1643. NetConnection.prototype.getService = function(serviceName, client)
  1644. {
  1645.    var result = new NetServiceProxy(this,serviceName,client);
  1646.    return result;
  1647. };
  1648. NetConnection.prototype.setCredentials = function(userid, password)
  1649. {
  1650.    this.addHeader("Credentials",false,{userid:userid,password:password});
  1651. };
  1652. NetConnection.prototype.RequestPersistentHeader = function(info)
  1653. {
  1654.    this.addHeader(info.name,info.mustUnderstand,info.data);
  1655. };
  1656. NetConnection.prototype.ReplaceGatewayUrl = function(newUrl)
  1657. {
  1658.    this.connect(newUrl);
  1659. };
  1660. NetConnection.prototype.clone = function()
  1661. {
  1662.    var nc = new NetConnection();
  1663.    nc.connect(this.uri);
  1664.    return nc;
  1665. };
  1666. if(_global.NetServices == null)
  1667. {
  1668.    _global.NetServices = new Object();
  1669.    NetServices.gatewayUrl = gatewayUrl;
  1670. }
  1671. NetServices.setDefaultGatewayUrl = function(url)
  1672. {
  1673.    NetServices.defaultGatewayUrl = url;
  1674. };
  1675. NetServices.setGatewayUrl = function(url)
  1676. {
  1677.    NetServices.gatewayUrl = url;
  1678. };
  1679. NetServices.createGatewayConnection = function(url)
  1680. {
  1681.    if(url == undefined)
  1682.    {
  1683.       if(NetServices.isHttpUrl(_root._url))
  1684.       {
  1685.          url = NetServices.gatewayUrl;
  1686.          if(url == undefined)
  1687.          {
  1688.             url = NetServices.defaultGatewayUrl;
  1689.             if(url != undefined)
  1690.             {
  1691.                if(NetServices.isHttpUrl(url))
  1692.                {
  1693.                   var firstSlashPos = url.indexOf("/",8);
  1694.                   if(firstSlashPos >= 0)
  1695.                   {
  1696.                      url = url.substring(firstSlashPos);
  1697.                   }
  1698.                }
  1699.                var hostUrl = NetServices.getHostUrl();
  1700.                if(hostUrl != null)
  1701.                {
  1702.                   url = hostUrl + url;
  1703.                }
  1704.             }
  1705.          }
  1706.       }
  1707.       else
  1708.       {
  1709.          url = NetServices.defaultGatewayUrl;
  1710.       }
  1711.    }
  1712.    if(url == undefined)
  1713.    {
  1714.       NetServices.trace("NetServices","warning",4,"createGatewayConnection - gateway url is undefined");
  1715.       return null;
  1716.    }
  1717.    var nc = new NetConnection();
  1718.    nc.connect(url);
  1719.    return nc;
  1720. };
  1721. NetServices.getHostUrl = function()
  1722. {
  1723.    if(!NetServices.isHttpUrl(_root._url))
  1724.    {
  1725.       return null;
  1726.    }
  1727.    var firstSlashPos = _root._url.indexOf("/",8);
  1728.    if(firstSlashPos < 0)
  1729.    {
  1730.       return null;
  1731.    }
  1732.    return _root._url.substring(0,firstSlashPos);
  1733. };
  1734. NetServices.isHttpUrl = function(url)
  1735. {
  1736.    return url.indexOf("http://") == 0 || url.indexOf("https://") == 0;
  1737. };
  1738. NetServices.trace = function(who, severity, number, message)
  1739. {
  1740.    var fullMessage = who + " " + severity + " " + number + ": " + message;
  1741.    trace(fullMessage);
  1742.    NetDebug.traceNetServices(who,severity,number,message);
  1743. };
  1744. NetServices.getVersion = function()
  1745. {
  1746.    return 1;
  1747. };
  1748. _global.DataGlue = function(dataProvider)
  1749. {
  1750.    this.dataProvider = dataProvider;
  1751. };
  1752. _global.DataGlue.bindFormatStrings = function(dataConsumer, dataProvider, labelString, dataString)
  1753. {
  1754.    var proxy = new DataGlue(dataProvider);
  1755.    proxy.labelString = labelString;
  1756.    proxy.dataString = dataString;
  1757.    proxy.getItemAt = _global.DataGlue.getItemAt_FormatString;
  1758.    dataConsumer.setDataProvider(proxy);
  1759. };
  1760. _global.DataGlue.bindFormatFunction = function(dataConsumer, dataProvider, formatFunction)
  1761. {
  1762.    var proxy = new DataGlue(dataProvider);
  1763.    proxy.formatFunction = formatFunction;
  1764.    proxy.getItemAt = _global.DataGlue.getItemAt_FormatFunction;
  1765.    dataConsumer.setDataProvider(proxy);
  1766. };
  1767. _global.DataGlue.prototype.addView = function(viewRef)
  1768. {
  1769.    return this.dataProvider.addView(viewRef);
  1770. };
  1771. _global.DataGlue.prototype.getLength = function()
  1772. {
  1773.    return this.dataProvider.getLength();
  1774. };
  1775. _global.DataGlue.prototype.format = function(formatString, record)
  1776. {
  1777.    var tokens = formatString.split("#");
  1778.    var result = "";
  1779.    var i = 0;
  1780.    while(i < tokens.length)
  1781.    {
  1782.       result += tokens[i];
  1783.       result += tokens[i + 1] != "" ? record[tokens[i + 1]] : "#";
  1784.       i += 2;
  1785.    }
  1786.    return result;
  1787. };
  1788. _global.DataGlue.getItemAt_FormatString = function(index)
  1789. {
  1790.    var record = this.dataProvider.getItemAt(index);
  1791.    if(record == "in progress" || record == undefined)
  1792.    {
  1793.       return record;
  1794.    }
  1795.    return {label:this.format(this.labelString,record),data:(this.dataString != null ? this.format(this.dataString,record) : record)};
  1796. };
  1797. _global.DataGlue.getItemAt_FormatFunction = function(index)
  1798. {
  1799.    var record = this.dataProvider.getItemAt(index);
  1800.    if(record == "in progress" || record == undefined)
  1801.    {
  1802.       return record;
  1803.    }
  1804.    return this.formatFunction(record);
  1805. };
  1806. _global.DataGlue.prototype.getItemID = function(index)
  1807. {
  1808.    return this.dataProvider.getItemID(index);
  1809. };
  1810. _global.DataGlue.prototype.addItemAt = function(index, value)
  1811. {
  1812.    return this.dataProvider.addItemAt(index,value);
  1813. };
  1814. _global.DataGlue.prototype.addItem = function(value)
  1815. {
  1816.    return this.dataProvider.addItem(value);
  1817. };
  1818. _global.DataGlue.prototype.removeItemAt = function(index)
  1819. {
  1820.    return this.dataProvider.removeItemAt(index);
  1821. };
  1822. _global.DataGlue.prototype.removeAll = function()
  1823. {
  1824.    return this.dataProvider.removeAll();
  1825. };
  1826. _global.DataGlue.prototype.replaceItemAt = function(index, itemObj)
  1827. {
  1828.    return this.dataProvider.replaceItemAt(index,itemObj);
  1829. };
  1830. _global.DataGlue.prototype.sortItemsBy = function(fieldName, order)
  1831. {
  1832.    return this.dataProvider.sortItemsBy(fieldName,order);
  1833. };
  1834. _global.RsDataProviderClass = function()
  1835. {
  1836.    this.init();
  1837. };
  1838. RsDataProviderClass.prototype.init = function()
  1839. {
  1840.    this.items = new Array();
  1841.    this.uniqueID = 0;
  1842.    this.views = new Array();
  1843. };
  1844. RsDataProviderClass.prototype.addView = function(viewRef)
  1845. {
  1846.    this.views.push(viewRef);
  1847.    var eventObj = {event:"updateAll"};
  1848.    viewRef.modelChanged(eventObj);
  1849. };
  1850. RsDataProviderClass.prototype.addItemAt = function(index, value)
  1851. {
  1852.    if(!this.checkLocal())
  1853.    {
  1854.       return undefined;
  1855.    }
  1856.    if(index < 0)
  1857.    {
  1858.       return undefined;
  1859.    }
  1860.    if(index < this.getLength())
  1861.    {
  1862.       this.items.splice(index,0,"tmp");
  1863.    }
  1864.    this.items[index] = new Object();
  1865.    if(typeof value == "object")
  1866.    {
  1867.       this.items[index] = value;
  1868.    }
  1869.    this.items[index].__ID__ = this.uniqueID++;
  1870.    var eventObj = {event:"addRows",firstRow:index,lastRow:index};
  1871.    this.updateViews(eventObj);
  1872. };
  1873. RsDataProviderClass.prototype.addItem = function(value)
  1874. {
  1875.    if(!this.checkLocal())
  1876.    {
  1877.       return undefined;
  1878.    }
  1879.    this.addItemAt(this.getLength(),value);
  1880. };
  1881. RsDataProviderClass.prototype.removeItemAt = function(index)
  1882. {
  1883.    if(!this.checkLocal())
  1884.    {
  1885.       return undefined;
  1886.    }
  1887.    if(index < 0 || index >= this.getLength())
  1888.    {
  1889.       return undefined;
  1890.    }
  1891.    var tmpItm = this.items[index];
  1892.    this.items.splice(index,1);
  1893.    var eventObj = {event:"deleteRows",firstRow:index,lastRow:index};
  1894.    this.updateViews(eventObj);
  1895.    return tmpItm;
  1896. };
  1897. RsDataProviderClass.prototype.removeAll = function()
  1898. {
  1899.    if(!this.checkLocal())
  1900.    {
  1901.       return undefined;
  1902.    }
  1903.    this.items = new Array();
  1904.    this.updateViews({event:"deleteRows",firstRow:0,lastRow:this.getLength() - 1});
  1905. };
  1906. RsDataProviderClass.prototype.replaceItemAt = function(index, itemObj)
  1907. {
  1908.    if(!this.checkLocal())
  1909.    {
  1910.       return undefined;
  1911.    }
  1912.    if(index < 0 || index >= this.getLength())
  1913.    {
  1914.       return undefined;
  1915.    }
  1916.    var tmpID = this.getItemID(index);
  1917.    this.items[index] = itemObj;
  1918.    this.items[index].__ID__ = tmpID;
  1919.    this.updateViews({event:"updateRows",firstRow:index,lastRow:index});
  1920. };
  1921. RsDataProviderClass.prototype.getLength = function()
  1922. {
  1923.    return this.items.length;
  1924. };
  1925. RsDataProviderClass.prototype.getItemAt = function(index)
  1926. {
  1927.    return this.items[index];
  1928. };
  1929. RsDataProviderClass.prototype.getItemID = function(index)
  1930. {
  1931.    return this.items[index].__ID__;
  1932. };
  1933. RsDataProviderClass.prototype.sortItemsBy = function(fieldName, order)
  1934. {
  1935.    if(!this.checkLocal())
  1936.    {
  1937.       return undefined;
  1938.    }
  1939.    this.items.sortOn(fieldName);
  1940.    if(order == "DESC")
  1941.    {
  1942.       this.items.reverse();
  1943.    }
  1944.    this.updateViews({event:"sort"});
  1945. };
  1946. RsDataProviderClass.prototype.updateViews = function(eventObj)
  1947. {
  1948.    var i = 0;
  1949.    while(i < this.views.length)
  1950.    {
  1951.       this.views[i].modelChanged(eventObj);
  1952.       i++;
  1953.    }
  1954. };
  1955. _global.RecordSet = function(columnNames)
  1956. {
  1957.    if(this.mTitles != null)
  1958.    {
  1959.       this.views = new Array();
  1960.       return undefined;
  1961.    }
  1962.    this.init();
  1963.    if(this.serverInfo == null)
  1964.    {
  1965.       this.mTitles = columnNames;
  1966.       return undefined;
  1967.    }
  1968.    if(this.serverInfo.version != 1)
  1969.    {
  1970.       NetServices.trace("RecordSet","warning",100,"Received incompatible recordset version from server");
  1971.       return undefined;
  1972.    }
  1973.    this.mTitles = this.serverInfo.columnNames;
  1974.    this.mRecordsAvailable = 0;
  1975.    this.setData(this.serverInfo.cursor != null ? this.serverInfo.cursor - 1 : 0,this.serverInfo.initialData);
  1976.    if(this.serverInfo.initialData.length != this.serverInfo.totalCount)
  1977.    {
  1978.       this.mRecordSetId = this.serverInfo.id;
  1979.       if(this.mRecordSetId != null)
  1980.       {
  1981.          this.serviceName = this.serverInfo.serviceName != null ? this.serverInfo.serviceName : "RecordSet";
  1982.          this.mTotalCount = this.serverInfo.totalCount;
  1983.          this.mDeliveryMode = "ondemand";
  1984.          this.mAllNotified = false;
  1985.          this.mOutstandingRecordCount = 0;
  1986.       }
  1987.       else
  1988.       {
  1989.          NetServices.trace("RecordSet","warning",102,"Missing some records, but there\'s no recordset id");
  1990.       }
  1991.    }
  1992.    this.serverInfo = null;
  1993. };
  1994. RecordSet.prototype = new RsDataProviderClass();
  1995. Object.registerClass("RecordSet",RecordSet);
  1996. RecordSet.prototype._setParentService = function(service)
  1997. {
  1998.    this.gateway_conn = service.nc;
  1999. };
  2000. RecordSet.prototype.getRecordSetService = function()
  2001. {
  2002.    if(this.mRecordSetService == null)
  2003.    {
  2004.       if(this.gateway_conn == null)
  2005.       {
  2006.          this.gateway_conn = NetServices.createGatewayConnection();
  2007.       }
  2008.       else if(_global.netDebugInstance != undefined)
  2009.       {
  2010.          this.gateway_conn = this.gateway_conn.clone();
  2011.       }
  2012.       if(_global.netDebugInstance != undefined)
  2013.       {
  2014.          this.gateway_conn.setupRecordset();
  2015.          this.gateway_conn.setDebugId("RecordSet " + this.mRecordSetId);
  2016.       }
  2017.       this.mRecordSetService = this.gateway_conn.getService(this.serviceName,this);
  2018.       if(this.mRecordSetService == null)
  2019.       {
  2020.          NetServices.trace("RecordSet","warning",101,"Failed to create recordset service");
  2021.          this.mRecordSetService = 0;
  2022.       }
  2023.    }
  2024.    return this.mRecordSetService;
  2025. };
  2026. RecordSet.prototype.getColumnNames = function()
  2027. {
  2028.    return this.mTitles;
  2029. };
  2030. RecordSet.prototype.getLength = function()
  2031. {
  2032.    if(this.mRecordSetID != null)
  2033.    {
  2034.       return this.mTotalCount;
  2035.    }
  2036.    return this.items.length;
  2037. };
  2038. RecordSet.prototype.getItemAt = function(index)
  2039. {
  2040.    if(this.mRecordSetId == null)
  2041.    {
  2042.       return this.items[index];
  2043.    }
  2044.    if(index < 0 || index >= this.getLength())
  2045.    {
  2046.       NetServices.trace("RecordSet","warning",104,"getItemAt(" + index + ") index out of range");
  2047.       return null;
  2048.    }
  2049.    this.requestRecord(index);
  2050.    var result = this.items[index];
  2051.    if(result == 1)
  2052.    {
  2053.       return "in progress";
  2054.    }
  2055.    return result;
  2056. };
  2057. RecordSet.prototype.setField = function(index, fieldName, value)
  2058. {
  2059.    if(!this.checkLocal())
  2060.    {
  2061.       return undefined;
  2062.    }
  2063.    if(index < 0 || index >= this.getLength())
  2064.    {
  2065.       return undefined;
  2066.    }
  2067.    this.items[index][fieldName] = value;
  2068.    this.updateViews({event:"updateRows",firstRow:index,lastRow:index});
  2069. };
  2070. RecordSet.prototype.filter = function(filterFunction, context)
  2071. {
  2072.    if(!this.checkLocal())
  2073.    {
  2074.       return undefined;
  2075.    }
  2076.    var result = new RecordSet(this.mTitles);
  2077.    var i = 0;
  2078.    while(i < this.getLength())
  2079.    {
  2080.       var item = this.getItemAt(i);
  2081.       if(item != null && item != 1 && filterFunction(item,context))
  2082.       {
  2083.          result.addItem(item);
  2084.       }
  2085.       i++;
  2086.    }
  2087.    return result;
  2088. };
  2089. RecordSet.prototype.sort = function(compareFunc)
  2090. {
  2091.    if(!this.checkLocal())
  2092.    {
  2093.       return undefined;
  2094.    }
  2095.    this.items.sort(compareFunc);
  2096.    this.updateViews({event:"sort"});
  2097. };
  2098. RecordSet.prototype.isLocal = function()
  2099. {
  2100.    return this.mRecordSetID == null;
  2101. };
  2102. RecordSet.prototype.isFullyPopulated = function()
  2103. {
  2104.    return this.isLocal();
  2105. };
  2106. RecordSet.prototype.getNumberAvailable = function()
  2107. {
  2108.    if(this.isLocal())
  2109.    {
  2110.       return this.getLength();
  2111.    }
  2112.    return this.mRecordsAvailable;
  2113. };
  2114. RecordSet.prototype.setDeliveryMode = function(mode, pagesize, numPrefetchPages)
  2115. {
  2116.    this.mDeliveryMode = mode;
  2117.    this.stopFetchAll();
  2118.    if(mode == "ondemand")
  2119.    {
  2120.       return undefined;
  2121.    }
  2122.    if(pagesize == null)
  2123.    {
  2124.       pagesize = this.views[0].getRowCount();
  2125.       if(pagesize == null)
  2126.       {
  2127.          pagesize = 25;
  2128.       }
  2129.    }
  2130.    if(mode == "page")
  2131.    {
  2132.       if(numPrefetchPages == null)
  2133.       {
  2134.          numPrefetchPages = 0;
  2135.       }
  2136.       this.mPageSize = pagesize;
  2137.       this.mNumPrefetchPages = numPrefetchPages;
  2138.    }
  2139.    else if(mode == "fetchall")
  2140.    {
  2141.       this.stopFetchAll();
  2142.       this.startFetchAll(pagesize);
  2143.    }
  2144.    else
  2145.    {
  2146.       NetServices.trace("RecordSet","warning",107,"SetDeliveryMode: unknown mode string");
  2147.    }
  2148. };
  2149. RecordSet.prototype.getRecords_Result = function(info)
  2150. {
  2151.    this.setData(info.Cursor - 1,info.Page);
  2152.    this.mOutstandingRecordCount -= info.Page.length;
  2153.    this.updateViews({event:"updateRows",firstRow:info.Cursor - 1,lastRow:info.Cursor - 1 + info.Page.length - 1});
  2154.    if(this.mRecordsAvailable == this.mTotalCount && !this.mAllNotified)
  2155.    {
  2156.       this.updateViews({event:"allRows"});
  2157.       this.mRecordSetService.release();
  2158.       this.mAllNotified = true;
  2159.       this.mRecordSetID = null;
  2160.       this.mRecordSetService = null;
  2161.    }
  2162. };
  2163. RecordSet.prototype.release_Result = function()
  2164. {
  2165. };
  2166. RecordSet.prototype.arrayToObject = function(anArray)
  2167. {
  2168.    if(this.mTitles == null)
  2169.    {
  2170.       NetServices.trace("RecordSet","warning",105,"getItem: titles are not available");
  2171.       return null;
  2172.    }
  2173.    var result = new Object();
  2174.    var i = 0;
  2175.    while(i < anArray.length)
  2176.    {
  2177.       var title = this.mTitles[i];
  2178.       if(title == null)
  2179.       {
  2180.          title = "column" + i + 1;
  2181.       }
  2182.       result[title] = anArray[i];
  2183.       i++;
  2184.    }
  2185.    return result;
  2186. };
  2187. RecordSet.prototype.setData = function(start, dataArray)
  2188. {
  2189.    var i = 0;
  2190.    while(i < dataArray.length)
  2191.    {
  2192.       var index = i + start;
  2193.       var rec = this.items[index];
  2194.       if(rec != null && rec != 1)
  2195.       {
  2196.          NetServices.trace("RecordSet","warning",106,"Already got record # " + recordIndex);
  2197.       }
  2198.       else
  2199.       {
  2200.          this.mRecordsAvailable += 1;
  2201.       }
  2202.       this.items[index] = this.arrayToObject(dataArray[i]);
  2203.       this.items[index].__ID__ = this.uniqueID++;
  2204.       i++;
  2205.    }
  2206. };
  2207. RecordSet.prototype.requestOneRecord = function(index)
  2208. {
  2209.    if(this.items[index] == null)
  2210.    {
  2211.       this.getRecordSetService().getRecords(this.mRecordSetId,index + 1,1);
  2212.       this.mOutstandingRecordCount = this.mOutstandingRecordCount + 1;
  2213.       this.items[index] = 1;
  2214.       this.updateViews({event:"fetchRows",firstRow:index,lastRow:index});
  2215.    }
  2216. };
  2217. RecordSet.prototype.requestRecord = function(index)
  2218. {
  2219.    if(this.mDeliveryMode != "page")
  2220.    {
  2221.       this.requestOneRecord(index);
  2222.       return undefined;
  2223.    }
  2224.    var firstIndex = int(index / this.mPageSize) * this.mPageSize;
  2225.    var lastIndex = firstIndex + this.mPageSize * (this.mNumPrefetchPages + 1) - 1;
  2226.    this.requestRecordRange(firstIndex,lastIndex);
  2227. };
  2228. RecordSet.prototype.requestRecordRange = function(index, lastIndex)
  2229. {
  2230.    var highestRequested = -1;
  2231.    if(index < 0)
  2232.    {
  2233.       index = 0;
  2234.    }
  2235.    if(lastIndex >= this.getLength())
  2236.    {
  2237.       lastIndex = this.getLength() - 1;
  2238.    }
  2239.    while(index <= lastIndex)
  2240.    {
  2241.       while(index <= lastIndex && this.items[index] != null)
  2242.       {
  2243.          index++;
  2244.       }
  2245.       var first = index;
  2246.       while(index <= lastIndex && this.items[index] == null)
  2247.       {
  2248.          this.mOutstandingRecordCount = this.mOutstandingRecordCount + 1;
  2249.          this.items[index] = 1;
  2250.          index++;
  2251.       }
  2252.       var last = index - 1;
  2253.       if(first <= last)
  2254.       {
  2255.          this.getRecordSetService().getRecords(this.mRecordSetId,first + 1,last - first + 1);
  2256.          highestRequested = last;
  2257.          this.updateViews({event:"fetchRows",firstRow:first,lastRow:last});
  2258.       }
  2259.    }
  2260.    return highestRequested;
  2261. };
  2262. RecordSet.prototype.startFetchAll = function(pagesize)
  2263. {
  2264.    this.mDataFetcher.disable();
  2265.    this.mDataFetcher = new RsDataFetcher(this,pagesize);
  2266. };
  2267. RecordSet.prototype.stopFetchAll = function()
  2268. {
  2269.    this.mDataFetcher.disable();
  2270.    this.mDataFetcher = null;
  2271. };
  2272. RecordSet.prototype.checkLocal = function()
  2273. {
  2274.    if(this.isLocal())
  2275.    {
  2276.       return true;
  2277.    }
  2278.    NetServices.trace("RecordSet","warning",108,"Operation not allowed on partial recordset");
  2279.    return false;
  2280. };
  2281. _global.RsDataFetcher = function(recordSet, increment)
  2282. {
  2283.    this.mRecordSet = recordSet;
  2284.    this.mRecordSet.addView(this);
  2285.    this.mIncrement = increment;
  2286.    this.mNextRecord = 0;
  2287.    this.mEnabled = true;
  2288.    this.doNext();
  2289. };
  2290. RsDataFetcher.prototype.disable = function()
  2291. {
  2292.    this.mEnabled = false;
  2293.    this.mRecordSet.removeView(this);
  2294. };
  2295. RsDataFetcher.prototype.doNext = function()
  2296. {
  2297.    if(!this.mEnabled)
  2298.    {
  2299.       return undefined;
  2300.    }
  2301.    while(true)
  2302.    {
  2303.       if(this.mNextRecord >= this.mRecordSet.getLength())
  2304.       {
  2305.          return undefined;
  2306.       }
  2307.       this.mHighestRequested = this.mRecordSet.requestRecordRange(this.mNextRecord,this.mNextRecord + this.mIncrement - 1);
  2308.       this.mNextRecord += this.mIncrement;
  2309.       if(this.mHighestRequested > 0)
  2310.       {
  2311.          return undefined;
  2312.       }
  2313.    }
  2314. };
  2315. RsDataFetcher.prototype.modelChanged = function(eventObj)
  2316. {
  2317.    if(eventObj.event == "updateRows" && eventObj.firstRow <= this.mHighestRequested && eventObj.lastRow >= this.mHighestRequested)
  2318.    {
  2319.       this.doNext();
  2320.    }
  2321.    if(eventObj.event == "allRows")
  2322.    {
  2323.       this.disable();
  2324.    }
  2325. };
  2326. trace("Try to Connect:");
  2327. if(isGatewayOpen == null)
  2328. {
  2329.    isGatewayOpen = true;
  2330.    NetServices.setDefaultGatewayUrl("http://tracking.exposurelab.com/flashservices/gateway");
  2331.    gatewayConnnection = NetServices.createGatewayConnection();
  2332.    exposure = gatewayConnnection.getService("exposuretracking",this);
  2333.    trace("FLASH: Connected");
  2334. }
  2335. trace("Try to Connect2:");
  2336. var pDirectorToFlashFinished = "no";
  2337. var pGeneral_RS = new Array();
  2338. var pSections_RS = new Array();
  2339. var pSuperSections_RS = new Array();
  2340. var pDownLoads_RS = new Array();
  2341. var pImages_RS = new Array();
  2342. var pFlashpaper_RS = new Array();
  2343. var pSectionViews = new Array();
  2344. var pSectionData = new Array();
  2345. var pDebugResults = "no";
  2346.